// with polyfills
// import 'babel-polyfill';
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/'
import { VueAxios } from './utils/request'
import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
import fileUpload from '@/components/upload/fileUpload.vue'
import imgUpload from '@/components/upload/imgUpload.vue'
import themePluginConfig from '../config/themePluginConfig'

// import bootstrap from './core/bootstrap'
import './core/use' // use lazy load components
import './permission' // permission control
import './utils/filter' // global filter
import './global.less' // global style
import "@/assets/comm/icon/iconfont.css"

import actions from '@/actions';

Vue.config.productionTip = false
Vue.use(VueAxios)
// use pro-layout components
Vue.component('pro-layout', ProLayout)
Vue.component('page-container', PageHeaderWrapper)
Vue.component('page-header-wrapper', PageHeaderWrapper)
Vue.component('fileUpload', fileUpload)
Vue.component('imgUpload', imgUpload)

window.umi_plugin_ant_themeVar = themePluginConfig.theme


import STable from '@/components/Table'

Vue.component("STable", STable);

import ECharts from 'vue-echarts'
Vue.component('chart', ECharts)

import moment from 'moment'
import { fileExport, fileDownload,fileDownloadByRequest, dateFormatter, mergeCell,fontSize} from '@/utils/util'
Vue.prototype.moment = moment
Vue.prototype.fileExport = fileExport
Vue.prototype.fileDownload = fileDownload
Vue.prototype.fileDownloadByRequest = fileDownloadByRequest
Vue.prototype.dateFormatter = dateFormatter
Vue.prototype.mergeCell = mergeCell
Vue.prototype.fontSize = fontSize

import './public-path'
import { SIDEBAR_TYPE } from '@/store/mutation-types';
if (window.__POWERED_BY_QIANKUN__) {
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

let instance = null;
function render(props = {}) {
  const { container } = props;
  instance = new Vue({
    store,
    router,
    render: (h) => h(App),
  }).$mount(container ? container.querySelector('#demo-child') : '#demo-child');

  if (props.actions) actions.setActions(props.actions)
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap() {
  console.log('[vue] vue app bootstraped');
}
export async function mount(props) {
  render(props);
}
export async function unmount() {
  instance.$destroy();
  instance.$el.innerHTML = '';
  instance = null;
}
